// display the momentum distributions of str, diff and total.
// the input file format is     mom    dsigma/dmom
// by Asia Sun, Feb. 04, 2023

static int co = 0; // graph color
void primp(TGraph *g); // primp the graph
const char *s = "strT.txt", *d = "difT.txt", *t = "tot.txt";

void mom(){
  TGraph *gstr = new TGraph(s, "%lg %lg"); primp(gstr);
  TGraph *gdif = new TGraph(d, "%lg %lg"); primp(gdif);
  TGraph *gtot = new TGraph(t, "%lg %lg"); primp(gtot);
  TLegend *lg = new TLegend(0.6, 0.7, 0.89, 0.89); lg->SetBorderSize(0);
  lg->AddEntry(gtot, "total");
  lg->AddEntry(gstr, "str.");
  lg->AddEntry(gstr, "diff.");

  TCanvas *c = new TCanvas("c", "c", 800, 600);
  gtot->Draw();
  gstr->Draw("same");
  gdif->Draw("same");
  lg->Draw();
} // end main function mom

// primp the graph
void primp(TGraph *g){
  TAxis *ax = g->GetXaxis(); ax->SetTitle("p_{c} [MeV/c]"); ax->CenterTitle();
  TAxis *ay = g->GetYaxis(); ay->SetTitle("d\\sigma_{-n}/dp_{c} [mb/(MeV/c)]");
  ay->CenterTitle();
  co++;
  if(5 == co || 10 == co) co++;
  g->SetLineColor(co); g->SetMarkerColor(co);
} // end function primp
